<?php

namespace falcon5\inc\Http\Views;

use falcon5\inc\Helpers\AssetsHelper;

/**
 * Class HttpView
 * @package falcon5\inc\Http\Views
 * @desc http视图
 */
class HttpView implements ViewInterface
{

    use JsonViewTrait;

    private $data = [];

    private $suffix = 'php';

    private $tpl;

    public function __construct($tpl = 'index')
    {
        $this->tpl = $tpl;
    }

    public function assign(array $params = [])
    {
        $this->data = $params;
    }

    public function render(array $params = [])
    {
        $params = array_merge($this->data, $params);
        return require_once( AssetsHelper::getTemplatePath() . "/" . $this->tpl . "." . $this->suffix );
    }
}